using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading;

namespace Tool.BaseClass
{
	public abstract class GClass45
	{
		public class GClass46
		{
			public struct GStruct0
			{
				public string ApiUri
				{
					get;
					set;
				}

				public string Xml
				{
					get;
					set;
				}
			}

			public static void smethod_0(string string_0, string string_1)
			{
				GClass45.GClass46.GStruct0 gStruct = new GClass45.GClass46.GStruct0
				{
					ApiUri = string_0,
					Xml = string_1
				};
				Thread thread = new Thread(new ParameterizedThreadStart(GClass45.GClass46.smethod_1));
				thread.Start(gStruct);
			}

			private static void smethod_1(object object_0)
			{
				try
				{
					GClass45.GClass46.GStruct0 gStruct = (GClass45.GClass46.GStruct0)object_0;
					System.Net.WebClient webClient = new System.Net.WebClient();
					System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection();
					nameValueCollection.Add("XmlString", gStruct.Xml);
					webClient.UploadValues(gStruct.ApiUri, "POST", nameValueCollection);
				}
				catch
				{
				}
			}
		}

		public static void smethod_0(int int_0, int int_1, int int_2, int int_3, int int_4, string string_0, List<string> list_0)
		{
			string string_ = GClass47.Ver.ToString();
			string string_2 = GClass45.smethod_3();
			string string_3 = GClass45.smethod_1();
			string text = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
			text += "<Content>";
			text += "<ToolUsedRecord>";
			text = text + "<Version>" + GClass0.smethod_12(string_) + "</Version>";
			text = text + "<HostName>" + GClass0.smethod_12(string_2) + "</HostName>";
			text = text + "<IpAddress>" + GClass0.smethod_12(string_3) + "</IpAddress>";
			text = text + "<TotalNumber>" + GClass0.smethod_12(int_0.ToString()) + "</TotalNumber>";
			text = text + "<SuccessNumber>" + GClass0.smethod_12(int_1.ToString()) + "</SuccessNumber>";
			text = text + "<LogNumber>" + GClass0.smethod_12(int_2.ToString()) + "</LogNumber>";
			text = text + "<FailNumber>" + GClass0.smethod_12(int_3.ToString()) + "</FailNumber>";
			text = text + "<NotExistsNumber>" + GClass0.smethod_12(int_4.ToString()) + "</NotExistsNumber>";
			text = text + "<CatchError>" + GClass0.smethod_12(string_0) + "</CatchError>";
			text += "</ToolUsedRecord>";
			text += "<ToolUsedRecordUri>";
			foreach (string current in list_0)
			{
				text = text + "<Uri>" + GClass0.smethod_12(current) + "</Uri>";
			}
			text += "</ToolUsedRecordUri>";
			text += "</Content>";
			GClass45.GClass46.smethod_0(GClass47.Api, text);
		}

		private static string smethod_1()
		{
			string text = "";
			GClass45.smethod_2("http://www.coridc.com/ip", ref text);
			GClass45.smethod_2("http://ip.chinaz.com/", ref text);
			GClass45.smethod_2("http://ip.qq.com", ref text);
			GClass45.smethod_2("http://www.ip.cn/", ref text);
			GClass45.smethod_2("http://www.ip38.com/", ref text);
			GClass45.smethod_2("http://sz.bendibao.com/ip/", ref text);
			string result;
			if (string.IsNullOrEmpty(text))
			{
				try
				{
					System.Net.IPHostEntry iPHostEntry = System.Net.Dns.Resolve(System.Net.Dns.GetHostName());
					System.Net.IPAddress iPAddress = iPHostEntry.AddressList[0];
					result = iPAddress.ToString();
					return result;
				}
				catch
				{
					text = "";
				}
			}
			result = text;
			return result;
		}

		private static void smethod_2(string string_0, ref string string_1)
		{
			if (string.IsNullOrEmpty(string_1))
			{
				try
				{
					using (System.Net.WebClient webClient = new System.Net.WebClient())
					{
						string input = webClient.DownloadString(string_0);
						System.Text.RegularExpressions.MatchCollection matchCollection = new System.Text.RegularExpressions.Regex("[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}", System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Singleline).Matches(input);
						if (matchCollection.Count > 0)
						{
							string_1 = matchCollection[0].Value.Trim();
						}
					}
				}
				catch
				{
				}
			}
		}

		private static string smethod_3()
		{
			return "";
		}
	}
}
